<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class trimesterguide extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct() {
		parent::__construct();
		ini_set('session.cookie_httponly',1); 
		ini_set('session.use_only_cookies',1);
		$this->load->model('trimesterguide_class');
	}	 
	public function list_trimesterguide(){
		$data=array();
		$post = $this->input->post();
		
		$trimesterguide = $this->trimesterguide_class->list_trimesterguide($post);
		if($trimesterguide!=0){
			foreach($trimesterguide as $key=>$value){
				$data['intID'][$key]=$value['intID'];
				$data['strTitle'][$key]=$value['strTitle'];
				$data['strNote'][$key]=$value['strNote'];
				$data['strImgLink'][$key]=$value['strImgLink'];
				$data['intOrder'][$key]=$value['intOrder'];
				$data['intCode'][$key]=$value['intCode'];
			}
		}
		echo json_encode($data);
	}
	public function save_trimesterguide(){
		$post = $this->input->post();
		$message = '';
		$trimesterguide = $this->trimesterguide_class->get_trimesterguide($post);
	
		if($trimesterguide!=0){
			$message = $this->trimesterguide_class->update($post);
		}
		else {
			$message = $this->trimesterguide_class->insert($post);
		}
		echo json_encode($message);
	}	

	public function get_trimesterguide(){
		$post = $this->input->post();
		$trimesterguide = $this->trimesterguide_class->get_trimesterguide($post);
		echo json_encode($trimesterguide);
	}
	public function delete_trimesterguide(){
		$post = $this->input->post();
		$trimesterguide = $this->trimesterguide_class->delete($post);
		echo json_encode($trimesterguide);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */